package jp.ddo.trismegistos.action.impl.entry;

import jp.ddo.trismegistos.action.impl.AbstractAction;
import jp.ddo.trismegistos.annotation.LoginCheck;
import jp.ddo.trismegistos.bean.UserInfo;
import jp.ddo.trismegistos.exception.RsException;
import jp.ddo.trismegistos.service.EntryService;

/**
 * @author Nagai Satoshi
 */
@LoginCheck
public class CompleteAction extends AbstractAction {

	private EntryService entryService;

	@Override
	public String execute() throws RsException {
		if (getParameter("back") != null) {
			setRequest("title", getSession("title"));
			setRequest("text", getSession("text"));
			removeSession("title");
			removeSession("text");
			return "entry/input.jsp";
		}

		final UserInfo userInfo = (UserInfo) getSession("userInfo");
		final String userId = "hoge";//userInfo.getUserId();

//		final int addCnt = entryService.addEntry(userId,
//				(String) getSession("title"), (String) getSession("text"));
//		if (addCnt != 1) {
//			// TODO
//		}
		removeSession("title");
		removeSession("text");
		return "entry/complete.jsp";
	}

	public void setEntryService(final EntryService entryService) {
		this.entryService = entryService;
	}
}
